// asserts/component/common/bottom-bar/bottom-bar.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    barList: Array
  },

  /**
   * 组件的初始数据
   */
  data: {
    iconList: [],
    activeNum: 0
  },

  /**
   * 组件的方法列表
   */
  methods: {
    choose: function(event) {
      var index = event.currentTarget.dataset.index;
      if(index != this.data.activeNum){
        var item = event.currentTarget.dataset.item;
        wx.redirectTo({
          url: item.path,
        })
      }
    }
  },
  lifetimes: {
    attached: function() {
      var index;
      for(var i = 0;i< this.properties.barList.length;i++) {
        if(this.properties.barList[i].active) {
          index = i;
          break;
        }
      }
      this.setData({
        iconList: this.properties.barList,
        activeNum: index
      })
    }
  }
})
